//计分器类
import {Sprite} from "../base/Sprite.js";
import {DataStore} from "../base/DataStore.js";
const screenWidth    = window.innerWidth
const screenHeight   = window.innerHeight
const rpx=DataStore.getRpx()

export class Score extends Sprite{

    constructor() {
        super()
        this.ctx = DataStore.getInstance().ctx;
        this.scoreNumber = 0;
        this.bottle=0;
        //因为canvas刷新的很快，所以需要一个变量控制加分，只加一次
        this.isScore = true;
    }
    drawInterviewTit(){
        const image = Sprite.getImage('interviewTit');
        super.draw(image,
            0, 0,
            image.width, image.height,
            (screenWidth-image.width/2*rpx)/2,20,
            image.width/2*rpx, image.height/2*rpx);
    }
    draw() {
        this.ctx.font = '25px Arial';
        this.ctx.fillStyle = '#fff';
        this.ctx.lineWidth = 5
        
        this.ctx.strokeText(
            this.scoreNumber,
            DataStore.getInstance().canvas.width / 2+25+110,
            DataStore.getInstance().canvas.height / 18+30,
            1000)
        this.ctx.fillText(
            this.scoreNumber,
            DataStore.getInstance().canvas.width / 2+25+110,
            DataStore.getInstance().canvas.height / 18+30,
            1000
        );
    }

    drawGold() {
        this.ctx.font = '25px Arial';
        this.ctx.fillStyle = '#fff';
        this.ctx.lineWidth = 5
        
        this.ctx.strokeText(
            this.bottle,
            DataStore.getInstance().canvas.width / 2+25,
            DataStore.getInstance().canvas.height / 18+30,
            1000)
        this.ctx.fillText(
            this.bottle,
            DataStore.getInstance().canvas.width / 2+25,
            DataStore.getInstance().canvas.height / 18+30,
            1000
        );
    }
}